/* 
 * File:   netcdfWrite.hpp
 * Author: gian
 *
 * Created on April 27, 2012, 12:49 PM
 */

#ifndef NETCDFWRITE_HPP
#define	NETCDFWRITE_HPP

#include <netcdfcpp.h>
#include "vector.hpp"


class netcdf_os_complex_float {
public:
    netcdf_os_complex_float(const char* filename, const char* channelname, int framesize=1024);
    virtual ~netcdf_os_complex_float();
    void write(cvectorf* data);
    void write(vectorf* redata, vectorf* imdata);
    void set_rate(double dt);
    void set_checkpoint_size(int numframes);
private:
    void OpenFile();
    void DataFlush();
    void DataCheckpoint();
    NcFile *mFile;
    long mRecord;
    int mDataPtr;
    int mFrameSize;
    float *mDataRe;
    float *mDataIm;
    double mDt;
    int mRecordCheckpointSize;
    int mCheckpointCount;
    std::string mFilename;
    std::string mChannelname;
};

class netcdf_os_double  {
public:
    netcdf_os_double(const char* filename, const char* channelname, int framesize=1024);
    virtual ~netcdf_os_double();
    void write(vector* data);
    void set_rate(double dt);
    void set_checkpoint_size(int numframes);
private:
    void OpenFile();
    void DataFlush();
    void DataCheckpoint();
    NcFile *mFile;
    long mRecord;
    int mDataPtr;
    int mFrameSize;
    double *mData;
    double mDt;
    int mRecordCheckpointSize;
    int mCheckpointCount;
    std::string mFilename;
    std::string mChannelname;    
};

class netcdf_os_float  {
public:
    netcdf_os_float(const char* filename, const char* channelname, int framesize=1024);
    virtual ~netcdf_os_float();
    void write(vectorf* data);
    void set_rate(double dt);
    void set_checkpoint_size(int numframes);
private:
    void OpenFile();
    void DataFlush();
    void DataCheckpoint();
    NcFile *mFile;
    long mRecord;
    int mDataPtr;
    int mFrameSize;
    float *mData;
    double mDt;
    int mRecordCheckpointSize;
    int mCheckpointCount;
    std::string mFilename;
    std::string mChannelname;    
};


#endif	/* NETCDFWRITE_HPP */

